Initiating Checkout - PayMaya/paymaya-ruby-sdk GitHub Wiki
To generate a checkout page through the Ruby SDK, call Paymaya::Checkout::Checkout.create
, with a hash containing the checkout parameters, as shown in the code snippet below:
valid_checkout = {
total_amount: {
currency: 'PHP',
value: '1234.56'
},
buyer: {
first_name: 'Grayson',
middle_name: 'Eichmann',
last_name: 'Howe',
contact: {
phone: '(477) 575-5820',
email: '[email protected]'
},
shipping_address: {
line1: '9F Robinsons Cybergate 3',
line2: 'Pioneer Street',
city: 'Mandaluyong City',
state: 'Metro Manila',
zip_code: '12345',
country_code: 'PH'
},
billing_address: {
line1: '9F Robinsons Cybergate 3',
line2: 'Pioneer Street',
city: 'Mandaluyong City',
state: 'Metro Manila',
zip_code: '12345',
country_code: 'PH'
},
ip_address: '129.180.98.95'
},
redirect_url: {
success: 'http://www.askthemaya.com/',
failure: 'http://www.askthemaya.com/failure?id=6319921',
cancel: 'http://www.askthemaya.com/cancel?id=6319921'
},
items: [
{
name: 'Heavy Duty Plastic Bag',
quantity: '3',
amount: {
value: '1621.10',
details: {
discount: '100.00',
subtotal: '1721.10'
}
},
total_amount: {
value: '4863.30',
details: {
discount: '300.00',
subtotal: '5163.30'}
}
}
],
request_reference_number: '000141386713',
metadata: {}
}
Paymaya::Checkout::Checkout.create valid_checkout
Checkout uses the following parameters in generating Checkout pages:
Hash Key | Description |
---|---|
:total_amount |
A hash containing details of the total amount |
:buyer |
A hash containing buyer information |
:redirect_url |
A hash containing up to three redirect URLs for the checkout payment events, with keys :success , :failure , :cancel |
:items |
An array of hashes containing checkout item details |
:request_reference_number |
An optional string containing an ID for the merchant's identification of the transaction |
:metadata |
An optional hash containing metadata about the transaction, for use by the merchant. Also contains submerchant information, if any |
:total_amount
contains the following information:
Hash Key | Description |
---|---|
:value |
A string containing the numerical value of the total amount, e.g. '1234.50' |
:currency |
ISO 4217 currency code, e.g. 'PHP' |
:details |
A hash containing the breakdown for :value . May contain the following keys (optional): :discount , :service_charge , :shipping_fee , :tax , :subtotal |
:buyer
contains the following information:
Hash Key | Description |
---|---|
:firstName |
A string containing the buyer's first name |
:middleName |
An optional string containing the buyer's middle name. Optional |
:lastName |
A string containing the buyer's last name |
:contact |
An optional hash containing the buyer's contact details, and can contain the following keys: :phone , :email |
:shippingAddress |
A hash containing the buyer's shipping address, and contains the following keys: :line1 , :line2 , :city , :state , :zip_code , :country_code |
:billingAddress |
A hash containing the buyer's billing address, and contains the following keys: :line1 , :line2 , :city , :state , :zip_code , :country_code |
:ipAddress |
A string containing the buyer's IP address |
:items
is an array of item hashes, containing the following information:
Hash Key | Description |
---|---|
:name |
Item name |
:quantity |
Item quantity |
:code |
Optional item code |
:description |
Optional description |
:amount |
Optional hash containing the breakdown of the total amount per individual item, with keys :value and :details . :details is a hash containing :subtotal and :discount |
:total_amount |
Hash containing the total amount of the items combined, with keys :value and :details . :details is a hash containing :subtotal and :discount |